﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FantastPlatform.Framework.Core;

namespace FantastPlatform.Framework.IService
{
    public interface IDataService<IEntity>
         where IEntity : IItem
    {
        /// <summary>
        /// 根据Id得到实体对象。若关联对象不存在，则为NULL，推荐使用
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        IEntity Get(object Id);
        /// <summary>
        /// 得到正在使用中的数据
        /// </summary>
        /// <returns></returns>
        IList<IEntity> LoadList(IList<Sort> sorts, int pageSize, int page, out int totalCount);
        /// <summary>
        /// 得到回收站中的数据
        /// </summary>
        /// <returns></returns>
        IList<IEntity> LoadLisDeleted(IList<Sort> sorts, int pageSize, int page, out int totalCount);
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity"></param>
        object Create(IEntity entity);
        /// <summary>
        /// 删除一条数据到回收站
        /// </summary>
        /// <param name="id"></param>
        void Delete(int id);
        /// <summary>
        /// 删除多条数据到回收站
        /// </summary>
        /// <param name="ids"></param>
        void Delete(List<int> ids);
        /// <summary>
        /// 彻底删除多条数据
        /// </summary>
        /// <param name="ids"></param>
        void DeleteReally(List<int> ids);
        /// <summary>
        /// 还原数据
        /// </summary>
        /// <param name="ids"></param>
        void RollBack(List<int> ids);
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="entity"></param>
        void Update(IEntity entity);
        /// <summary>
        /// 刷新
        /// </summary>
        /// <param name="entity"></param>
        void Refresh(IEntity entity);
        /// <summary>
        /// 按条件查询
        /// </summary> 
        /// <param name="conditionGroup"></param>
        /// <param name="sorts"></param>
        /// <param name="pageSize"></param>
        /// <param name="page"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        IList<IEntity> Search(ConditionGroup conditionGroup, IList<Sort> sorts, int pageSize, int page, out int totalCount);
    }
}
